﻿Imports system.Data.SqlClient
Public Class ThemMonHoc

    Private Sub btnThem_Click(sender As System.Object, e As System.EventArgs) Handles btnThem.Click
        Dim con As SqlConnection = New SqlConnection()
        con.ConnectionString = Ketnoi.str
        con.Open()
        Dim cmd As SqlCommand = New SqlCommand()
        cmd.Connection = con
        Dim SoTrinh As Integer
        SoTrinh = Convert.ToInt16(txtSoTrinh.Text)
        cmd.CommandText = "INSERT INTO MonHoc VALUES('" + txtMaMonHoc.Text + "','" + txtTenMonHoc.Text + "'," + SoTrinh + ",'" + txtGiangVien.Text + "')"
        cmd.ExecuteNonQuery()
        Dim result As DialogResult
        result = MessageBox.Show("THÊM DỮ LIỆU THÀNH CÔNG", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        If result = DialogResult.OK Then
            Me.Close()
            Dim frm As ThemMonHoc = New ThemMonHoc()
            frm.Show()
        End If
    End Sub

    Private Sub btnThoat_Click(sender As System.Object, e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
        Dim frm As DanhSachMonHoc = New DanhSachMonHoc()
        frm.Show()

    End Sub
End Class